package akka.greeting;

import akka.actor.AbstractActor;
import akka.actor.Props;
import akka.event.Logging;
import akka.event.LoggingAdapter;

/**
 * Created by Arnold on 2018/8/7.
 */
public class Printer extends AbstractActor {

  private LoggingAdapter log = Logging.getLogger(getContext().getSystem(), this);

  public static Props props() {
    return Props.create(Printer.class, () -> new Printer());
  }

  static public class Greeting {
    public final String message;

    public Greeting(String message) {
      this.message = message;
    }
  }

  @Override
  public Receive createReceive() {
    return receiveBuilder()
      .match(String.class, greeting -> {
        log.info(greeting);
      })
      .build();
  }

  public Printer() {
  }

}
